package com.sinopec.basemodule.utils.kotlin

import org.junit.Test

import java.util.regex.Pattern

/**
 * 创建人：lwj<br></br>
 * 创建时间：2019/8/5 11:05 <br></br>
 */
class StringEKtTest {

    @Test
    fun formatDoubleStr() {
    }

    @Test
    fun parseInt() {
    }

    @Test
    fun parseScanCodeErrorHint() {
        //val s = "存在在库托盘33块，无法入库！11 11 12 25 21 21"
        val s = "存在在库托盘1块，无法出库！86 3B C0 14 02 14"
        println(s)
        println("------")
        val p = Pattern.compile("^(\\D*\\d+\\D*！).*")
        val matcher = p.matcher(s)
        //println(matcher.find())
        //println(matcher.groupCount())
        if (matcher.find()) {
            println(matcher.group(1))
        }
        /*for (i in 0..matcher.groupCount()) {
            println(matcher.group(i))
        }*/
        println("----------------------")
        val p2  = Pattern.compile("\\D*([0-9A-Z]+ [0-9A-Z]+ [0-9A-Z]+ [0-9A-Z]+ [0-9A-Z]+ [0-9A-Z]+)\\D*")
        val matcher2 = p2.matcher(s)
       // println(matcher2.find())
        while (matcher2.find()) {
            //println(matcher2.groupCount())
            /*for (i in 0..matcher2.groupCount()) {
                println(matcher2.group(i))
            }*/
            println(matcher2.group(1))
            println("--")
        }
    }
}